

from Tkinter import *
import webbrowser

screen = Tk() 

screen.geometry("300x720")

screen.columnconfigure(0, minsize=10)#300) <-- changes the margin

door=PhotoImage(file="watercolour.gif") 
knock = Label(screen, image = door)
g = 0
d = 0
knock.place(x = g, y = d, width= 40, height= 40)

def knockknock(g, d):
    while d < 720: #72 in honour of art bell
        knock = Label(screen, image = door)
        knock.place(x =g, y = d, width=40, height = 40)
        d = d + 40 
    
while g < 300:
    knockknock(g, d)
    g = g + 40

#textholder2 = Label(screen, image = door, height = 40)  ###'
#textholder2.grid(row=10, column=0 )

screen.title('Fast Impressions')
textholder0 = Label(screen, image = door, height = 40) #Label(textholder0.grid(row=1, column=0)
title = Label(screen, text="Fast Impressions",width = 30,height = 2, background = "#a4a2ff", foreground = '#91ffbf',font = "Ariel 11 italic bold")
title.grid(row=4, column=0)
clear = Label(screen, height = 1)
clear.grid(row = 5, column=1)

text1 = Label(screen, background='#FEFDFF', text="Name or phrase?")
text1.grid(row=6, column=0)

abreakone = StringVar()
aabreak = Entry(screen, textvariable=abreakone, width = 25, highlightbackground = '#a4a2ff')#E085FF') 
aabreak.grid(row=7, column=0)
#ab = abreakone.get() #-------------------------

text2 = Label(screen, background='#FEFDFF', text="Year of birth / creation?")
text2.grid(row=8, column=0)

yv = IntVar()
yyear = Entry(screen, textvariable=yv, width = 25, highlightbackground = '#a4a2ff')
yyear.grid(row=9, column=0)#padx=10)
text3 = Label(screen, background='#FEFDFF', text="Month?") # make a April = 4 etc. etc. in main
text3.grid(row=10, column=0)

mv = IntVar()
mmonth = Entry(screen, textvariable=mv, highlightbackground = '#a4a2ff', width = 25) 
mmonth.grid(row=11, column=0)
text4 = Label(screen, background='#FEFDFF', text="Date(day)?")
text4.grid(row=12, column=0)
dv = IntVar()
dday = Entry(screen, textvariable=dv, highlightbackground = '#a4a2ff', width = 25)
dday.grid(row=13, column=0) 
#dayp = dv.get()
clear = Label(screen, height = 1)
clear.grid(row = 15, column=1)
ask = Button(screen, background='#91ffbf',activebackground = "#a4a2ff", text= "Do a single calculation now",command = lambda:figureitout().firstask(themoreyouignoreme))
ask.grid(row = 14, column = 0)

    
doctor = PhotoImage(file = "sbs.gif")
detroit = Button(screen, image = doctor, command = lambda: webbrowser.open('http://www.swagbucks.com/refer/DoctorDetroit'))
detroit.grid(row = 16, column = 0)

clear = Label(screen, height = 1)
clear.grid(row = 20, column=1)
text6 = Label(screen,background="#FEFDFF", text="Second name or phrase?")
text6.grid(row=21, column=0)
name2 = Entry(screen, width = 25, highlightbackground = "#a4a2ff")
name2.grid(row=22)
text7 = Label(screen,background= "#FEFDFF", text="Second year of birth or creation?")
text7.grid(row=23, column=0)
year2 = Entry(screen, width = 25, highlightbackground = "#a4a2ff")
year2.grid(row=24, column=0)
text8 = Label(screen, background="#FEFDFF", text="Second month?") # make a April = 4 etc. etc. in main
text8.grid(row=25, column=0)
month2 = Entry(screen, width = 25, highlightbackground = "#a4a2ff")
month2.grid(row=26, column=0)
text9 = Label(screen, background='#FEFDFF', text="Second day?")
text9.grid(row=27, column=0)
day = Entry(screen, background='#FEFDFF', width = 25, highlightbackground = "#a4a2ff")
day.grid(row=30, column=0)

ask2 = Button(screen, background='#91ffbf',activebackground = "#a4a2ff", text= "See test matches now",command = lambda:secondask(), height = 1) 
ask2.grid(row = 31, column = 0) #get some sort of padding

global themoreyouignoreme
themoreyouignoreme = [] #lisynames
global thecloseriget
thecloseriget = []

zone = "\n\nAssertive - Dominating - Driven - Egotistic - Impulsive - Individualistic - Leader\n\n"

ztwo = "\n\nAdaptable - Considerate - Depression prone - Diplomat - Drowns in detail - Influenceable - Modest - Self conscious - Timid\n\n"

zthree = "\n\nCreative - Enjoys life - Exagerates - Expressive - Flighty - Insightful - Moody - Resilient - Verbal\n\n"

zfour = "\n\nAcheiver - Argumentative - Dislikes limits -  Drowns in details - Lack of imagination - Orderly - Practical - Slow to act - Steady Growth\n\n"

zfive = "\n\nEdgy temperment - Curious - Ever changing - Hasty - Impatient - Pissy if held back - Restless - Versitile - Visionary\n\n"

zsix = "\n\nArtistic - Domestic - Likes flattery - Meddling - Outspoken - Self Righteous - Stubbourn - Sympathetic - Very Responsible\n\n"

zseven = "\n\nCharming - Hates distractions - Inflexible - Loves solitude - Perfectionist - Sarcastic - Scheming - Studious - Suspicious\n\n"

zeight = "\n\nAltruistic - Can make much money but also mismanage it - Handles power and authority well - Impatient - Materialistic - Political skills - Sound judgment - Values recognition - Workaholic\n\n"

znine = "\n\nCreative - Friendly - Humanitarian - Meets obligations - Moody - Possessive - Prone to peer pressure - Scattered interests - Selfless\n\n"

zzero = "\n \n"

class figureitout:
    global themoreyouignoreme
    themoreyouignoreme = []
    global thecloseriget
    thecloseriget = []
    global percenties
    percenties = []
    # global neutrals
    # neutrals = 0
    # global compatiblematches
    # compatiblematches = 0
    # global naturalmatches
    # naturalmatches = 0
    # global challenges

 


    chalenges = 0
    global vowelsOnly
    vowelsOnly = list()
    global consOnly  
    consOnly = list()
    global vows
    vows = ['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O','u', 'U']
    global vowgroup
    vowgroup = list()
    global consgroup
    consgroup = list()
    global vibes
    vibes = {
    1:(["a","A", "j","J", "S", "s", "1"],[1]),
    2:(["B","b", "K", "k", "T", "t", "2"], [2]),
    3:(["C","c","L", "l","U", "u", "3"], [3]),
    4:(["d", "D", "M", "m", "V", "v", "4"], [4]),
    5:(["e", "E", "N", "n", "W", "w", "5"], [5]),
    6:(["f", "F", "O", "o", "x", "X", "6"], [6]),
    7:(["g", "G", "P", "p","Y", "y", "7"], [7]),
    8:(["h", "H", "Q", "q","Z", "z", "8"], [8]),
    9:(["i", "I", "R", "r", "9"], [9])
    }


    def askdown(self,abreak, year, month, day, lisyname):    
        alphabreak = list(abreak)
        looseit(alphabreak, "'")
        numerals(year, month, day)
        while "y" in alphabreak:
            why("y", alphabreak)
            continue
        
        for item in alphabreak:
            consOnly.append(item)

        del alphabreak

        sort(vows, consOnly, vowelsOnly)

        looseit(consOnly, " ")
        looseit(vowelsOnly, " ")
        gather(vowelsOnly, vowgroup)
        gather(consOnly, consgroup)
        global vowelzz
        vowelzz = totes(vowgroup)
        print vowelzz #ha ha maybe off by one it
        #vowelzz = vowelzz
        print vowelzz
        global conzz
        conzz = totes(consgroup)#numbers on the fly - new name?
        conzz = conzz
        global allzz
        allzz  = vowelzz + conzz
        allzz = reducer(allzz)
        print"ok"
        print vowelzz
        wellokthen = (vowelzz, conzz, allzz, second, first)
        for item in wellokthen:
            lisyname.append(item)
            print "cottoncrown"
            print lisyname


            

        def ripart(whatnum): #can u put some sort of formating on strings
            if whatnum == 1:
                whatnum = "1" + zone
            elif whatnum == 0:
                whatnum = "0" + zzero
            elif whatnum == 2:
                whatnum = "2" + ztwo
            elif whatnum == 3:
                whatnum = "3" + zthree
            elif whatnum == 4:
                whatnum = "4" + zfour
            elif whatnum == 5:
                whatnum = "5" + zfive
            elif whatnum == 6:
                whatnum = "6" + zsix
            elif whatnum == 7:
                whatnum = "7" + zseven
            elif whatnum == 8:
                whatnum = "8" + zeight
            elif whatnum == 9:
                whatnum = "9" + znine
            else:
                pass
            return whatnum

        vowelzt = ripart(vowelzz)
        conzt = ripart(conzz)
        allzt = ripart(allzz)
        secondt = ripart(second)
        firstt = ripart(first)
        print vowelzt
                
 

        singlenametext = "\n\nVowels (private ambitions) break down to %s \n\nConsants (secret dreams) break down to %s \n\nAll letters together (life mission) break down to %s \n\nThe birthday and month (first impression people have) break down to %s \n\nAll the birthnumbers together (dominant traits) break down to %s "  % (vowelzt, conzt, allzt, secondt, firstt) #double check nothing with date alone
        
        if lisyname == themoreyouignoreme:
            popdisplay(singlenametext, "First Name Calculation")
        elif lisyname == thecloseriget:
            popdisplay(singlenametext, "Second Name Calculation")
                

    def firstask(self,lisyname):
        ab = abreakone.get()
        yearp = yv.get()
        monthp = mv.get()
        dayp = dv.get()
        self.askdown(ab, yearp, monthp, dayp, lisyname)


def reducer(stuff):
    while len(list(map(int, str(stuff)))) > 3:
        stuff  = list(map(int, str(stuff)))[0] + list(map(int,
str(stuff)))[1] + list(map(int, str(stuff)))[2] + list(map(int,
str(stuff)))[3]
    while len(list(map(int, str(stuff)))) > 2:
        stuff  = list(map(int, str(stuff)))[0] + list(map(int,
str(stuff)))[1] + list(map(int, str(stuff)))[2]
    while len(list(map(int, str(stuff)))) > 1:
        stuff  = list(map(int, str(stuff)))[0] + list(map(int, str(stuff)))[1]
    if stuff > 9:
        reducer(stuff)
    else:
        return stuff

def looseit(listofstuff, what):
    for whatever in listofstuff:
        if whatever == what:
            listofstuff.remove(what)


def numerals(year, month, day):
    secondpath = month + day
    thirdpath = year
    firstpath = secondpath + thirdpath
    global first
    first = reducer(firstpath)
    third = reducer(thirdpath)
    global second
    second = reducer(secondpath)
 

def sort(checklist, stuff, morestuff):
        for whatever in checklist: 
            while whatever in stuff:
                morestuff.append(whatever)
                stuff.remove(whatever)

def why(a, b):
    b.append(' ')
    b.insert(0, ' ')
    firstwhy = b.index(a)
    firstless = firstwhy -1
    firstmore = firstwhy +1
    if b[firstless] not in vows and b[firstmore] not in vows:
        vowelsOnly.append(a)
    else:
        consOnly.append(a)
    b.remove(a)


def gather(letters, groupz):
    x = 0
    while x <= len(vibes)-1:
        for item in letters:
            if item in vibes.values()[x][0]:
                groupz.append(vibes.values()[x][1])
        x = x +1

def totes(listy):
    global werk
    werk = 0
    for thing in listy:
        werk = werk + thing[0]
    if werk >= 10:
        werk = reducer(werk)
    return werk

def popdisplay(rushisthebestbandever, titlez):
    
    pops = Toplevel(background = '#ccccff')
    
    pops.title(titlez)
    pops.geometry("300x650")
    mess = Message(pops, justify = CENTER, text= rushisthebestbandever, background = "#ebdeff", width = 295)
    global percenties
    percenties = []
    mess.pack()

    okies = Button(pops, text="Okies, got it", bg = "#ffffff", command= pops.destroy)
    okies.pack()



def secondask():#themoreyouig):
    global themoreyouignoreme
    figureitout().firstask(themoreyouignoreme)
    print themoreyouignoreme
    print "stuck"
    global thecloseriget
    figureitout().firstask(thecloseriget)

    blink = 0
    while blink < 5:
        global themoreyouignoreme
        firsty = themoreyouignoreme[blink]
        global thecloseriget
        secondy = thecloseriget[blink]

        groupone = [3,6,9] # fworks so far!
        grouptwo = [1,5,7]
        groupthree = [2,4,8]
        tally = 0
        if firsty in groupone and secondy in groupone:
            tally += 100
        if firsty in grouptwo and secondy in grouptwo:
            tally +=  100
        if firsty in groupthree and secondy in groupthree:
            tally += 100

        print tally
         
        if tally != 0:
            global percenties
            percenties.append(tally)
   
        rally = 0
        if firsty == 5 and secondy == 9:
            rally += 75
        if firsty == 6 and secondy == 8:
            rally += 75
        if firsty == 3 and secondy == 5:
            rally += 75

        if rally != 0:
            global percenties
            percenties.append(rally)

        pally = 0
        if firsty == 1 and secondy == 8:
            pally += 50
        if firsty == 5 and secondy == 8:
            pally += 50
        if firsty == 8 and secondy == 5:
            pally += 50
        if firsty == 8 and secondy == 1:
            pally += 50

        if pally != 0:
            global percenties
            percenties.append(pally)

        fally = 0
        if tally == 0 and rally == 0 and pally == 0:
            fally += 25
        if fally != 0:
            global percenties
            percenties.append(fally)

        blink = blink + 1


    doublenametext = "\n\nVowels show as a %i  percent match \n\n Consonants show as a %i percent match \n\n All letters together show as a %i percent match \n\n Birthdates show as a  %i percent match \n\n All of the birth numbers together show as a %i percent match \n" % (percenties[0], percenties[1], percenties[2], percenties[3], percenties[4]) 

    popdisplay(doublenametext, "Match")
 
mainloop()




